// 配置路由的地方
import Vue from "vue";
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import Home from '@/pages/Home/home-index'
import Search from '@/pages/Search/search-index'
import Login from '@/pages/Login/login-index'
import Register from '@/pages/Register/register-index'
// 配置路由
export default new VueRouter({
    routes: [{
            path: '/home',
            component: Home,
            meta: {
                show: true
            }
        },
        {
            path: '/search/:keyword?',
            component: Search,
            meta: {
                show: true
            },
            name: "search",
            // 布尔值写法，只能params参数
            // props: true
            // 对象写法
            // props:{a:1,b:2}
            // 函数写法
            props: ($route) => {
                return {
                    keyword: $route.params.keyword,
                    k: $route.query.k
                }
            }
        }, {
            path: '/login',
            component: Login,
            meta: {
                show: false
            }
        }, {
            path: '/register',
            component: Register,
            meta: {
                show: false
            }
        },
        {
            path: '*',
            redirect: '/home'
        }
    ]
})